package util

import (
	"encoding/base64"
	"encoding/hex"
)

func Base64Encode(src []byte) string {
	return base64.StdEncoding.EncodeToString(src)
}

func Base64Decode(src string) []byte {
	b, err := base64.StdEncoding.DecodeString(src)
	if err != nil {
		panic(err)
	}
	return b
}

func Base64EncodeString(src string) string {
	return Base64Encode([]byte(src))
}
func Base64DecodeString(src string) string {
	r := Base64Decode(src)
	return string(r)
}

func BytesToHex(src []byte) string {
	return hex.EncodeToString(src)
}

func HexToBytes(src string) []byte {
	b, _ := hex.DecodeString(src)
	return b
}
